<template>
    <div id="tab">
        <ul>
            <li :class="current === i? 'active' : ''" v-for="(item,i) in tab" 
            :key="i" @click="tabClick(i)">{{item}}</li>
        </ul>
    </div>
</template>

<script>
export default {
    name: 'tab',
    props:{
        // 设置传过来的必须是数组
        tab:Array
    },
    data() {
        return {
            current:0
        };
    },
    created() {
    },
    methods: {
        tabClick(i) {
            this.current = i
            if(i ===0){
                this.$router.push('/')
            }else if(i === 1){
                this.$router.push('/types')
            }
        }

    },
    //组件挂载
    components: {},
    //计算属性
    computed: {},
    //过滤器
    filters: {},
};
</script>

<style lang="scss" scoped>
#tab{
    width: 100%;
    height: 1rem;
    ul{
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 100%;
        li{
            flex-basis: 25%;
            text-align: center;
            line-height: 1rem;
            font-size: .24rem;
        }
        .active{
            color: red;
        }
    }

}
</style>
